/**
 * Copyright (C) 2013 Oleg Anastassov <oleg.anastassov@gmail.com>
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package kz.kstu.loc.desktop.run;

import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
import kz.kstu.loc.util.GUIUtils;
import org.apache.log4j.Logger;

import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;

/**
 * Date: 28.12.2012
 * Time: 09:44
 *
 * @author Oleg Anastassov
 */
public class LocToolClient {

    private static final Logger LOGGER = Logger.getLogger(LocToolClient.class);

    public LocToolClient() {
    }

    public static void main(String[] args) {
        LocToolClient client = new LocToolClient();
        client.start();
    }

    public void start() {
        LookAndFeel lookAndFeel = new NimbusLookAndFeel();
        putOptionPaneMessages();
        putFileChooserMessages();
        try {
            UIManager.setLookAndFeel(lookAndFeel);
        } catch (UnsupportedLookAndFeelException e) {
            LOGGER.error(e.getMessage(), e);
        }

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                GUIUtils.centerAndShow(new AppDashboard());
            }
        };
        SwingUtilities.invokeLater(runnable);
    }

    /**
     * Костыльная русификация диалогов.
     */
    private void putOptionPaneMessages() {
        UIManager.put("OptionPane.cancelButtonMnemonic", "0");
        UIManager.put("OptionPane.cancelButtonText", "Отмена");
        UIManager.put("OptionPane.inputDialogTitle", "Ввод");
        UIManager.put("OptionPane.messageDialogTitle", "Сообщение");
        UIManager.put("OptionPane.noButtonMnemonic", "78");
        UIManager.put("OptionPane.noButtonText", "Нет");
        UIManager.put("OptionPane.okButtonMnemonic", "0");
        UIManager.put("OptionPane.okButtonText", "OK");
        UIManager.put("OptionPane.titleText", "Выберите значение");
        UIManager.put("OptionPane.yesButtonMnemonic", "89");
        UIManager.put("OptionPane.yesButtonText", "Да");
    }

    private void putFileChooserMessages() {
        UIManager.put("FileChooser.openDialogTitleText", "Открытие");
        UIManager.put("FileChooser.lookInLabelText", "Обзор");
        UIManager.put("FileChooser.openButtonText", "Открыть");
        UIManager.put("FileChooser.cancelButtonText", "Отмена");
        UIManager.put("FileChooser.fileNameLabelText", "Имя файла");
        UIManager.put("FileChooser.filesOfTypeLabelText", "Типы файлов");
        UIManager.put("FileChooser.openButtonToolTipText", "Открыть выбранный файл");
        UIManager.put("FileChooser.cancelButtonToolTipText", "Отмена");
        UIManager.put("FileChooser.fileNameHeaderText", "Имя файла");
        UIManager.put("FileChooser.upFolderToolTipText", "Вверх");
        UIManager.put("FileChooser.homeFolderToolTipText", "Рабочий стол");
        UIManager.put("FileChooser.homeFolderAccessibleName", "Рабочий стол");
        UIManager.put("FileChooser.newFolderToolTipText", "Создать папку");
        UIManager.put("FileChooser.listViewButtonToolTipText", "Список");
        UIManager.put("FileChooser.newFolderButtonText", "Создать папку");
        UIManager.put("FileChooser.renameFileButtonText", "Переименовать файл");
        UIManager.put("FileChooser.deleteFileButtonText", "Удалить файл");
        UIManager.put("FileChooser.filterLabelText", "Типы файлов");
        UIManager.put("FileChooser.detailsViewButtonToolTipText", "Подробно");
        UIManager.put("FileChooser.fileSizeHeaderText", "Размер");
        UIManager.put("FileChooser.fileDateHeaderText", "Изменен");
    }
}

